Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[CORE] OV file utils file_size use std file path #28462

Open
wants to merge 20 commits into
base: master
Choose a base branch
from

Conversation

barnasm1
Copy link
Contributor

Details:

  • refactor file_size function to accept ov::util::Path / std::filesystem::path. Be backward compatible with previous version.

Tickets:

@barnasm1 barnasm1 added the category: Core OpenVINO Core (aka ngraph) label Jan 15, 2025
@barnasm1 barnasm1 self-assigned this Jan 15, 2025
@barnasm1 barnasm1 requested review from a team as code owners January 15, 2025 15:26
@github-actions github-actions bot added the category: build OpenVINO cmake script / infra label Jan 15, 2025
@praasz praasz self-assigned this Jan 16, 2025
@praasz praasz added this to the 2025.1 milestone Jan 16, 2025
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These functions are not cast rename file or keep them in original header.
Why these function are moved to new file?

Comment on lines 40 to 51
#if defined(GCC_VER_LESS_THEN_12_3) || defined(CLANG_VER_LESS_THEN_17)
inline ov::util::Path WPath(const std::wstring& wpath) {
return {ov::util::wstring_to_string(wpath)};
}
#else
inline ov::util::Path WPath(const std::wstring& wpath) {
return {wpath};
}
#endif

} // namespace util
} // namespace ov
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
#if defined(GCC_VER_LESS_THEN_12_3) || defined(CLANG_VER_LESS_THEN_17)
inline ov::util::Path WPath(const std::wstring& wpath) {
return {ov::util::wstring_to_string(wpath)};
}
#else
inline ov::util::Path WPath(const std::wstring& wpath) {
return {wpath};
}
#endif
} // namespace util
} // namespace ov
} // namespace util
} // namespace ov
#if defined(GCC_VER_LESS_THEN_12_3) || defined(CLANG_VER_LESS_THEN_17)
template<>
ov::util::Path::path<std::wstring>(const std::wstring& source, format fmt) : path(ov::util::wstring_to_string(source), std::move(fmt)) {}
#endif

Consider add specialization for compiler version where is bug with path creation then WPath function is not required and path can be create always in same way.
Optionally: If any issue because specialization already defined add some trait check to detect it and avoid define it in OV.

src/common/util/include/openvino/util/cpp_version.hpp Outdated Show resolved Hide resolved
@@ -172,26 +161,30 @@ bool directory_exists(const std::string& path);
bool directory_exists(const std::wstring& path);
#endif

inline ov::util::Path cut_android_path(const ov::util::Path& file_name) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This function is not required can be still internal part of file_size

if (pos != std::string::npos) {
file_name = file_name.substr(0, pos);
}
inline int64_t file_size(const ov::util::Path& path) {
Copy link
Contributor

@praasz praasz Jan 16, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
inline int64_t file_size(const ov::util::Path& path) {
inline int64_t file_size(const ov::util::Path& path) {
#if defined(__ANDROID__) || defined(ANDROID)
// apply cuting if std::filesytem not support it well.
#endif
return std::filesystem::file_size(path);
}

This function should probably be wrapper to std implementation if works.

src/core/tests/file_util.cpp Show resolved Hide resolved
src/core/tests/file_util.cpp Outdated Show resolved Hide resolved
src/core/tests/file_util.cpp Outdated Show resolved Hide resolved
/**
* @brief Returns file size for file
* @param[in] path The file name
* @return file size
*/
[[deprecated(
"This function is deprecated use file_size(const ov::util::Path& path) instead. Will be removed in 2026.0")]]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's internal function (not given to end users) and can be removed right now (if it does not have other users)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
category: build OpenVINO cmake script / infra category: Core OpenVINO Core (aka ngraph)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants